package com.yx.front.controller;


import com.yx.front.config.global.CommonResult;
import com.yx.front.manager.BookCollectManager;
import com.yx.front.model.param.CollectParam;
import com.yx.front.model.param.SysUserParam;
import com.yx.front.model.vo.BookMessageVo;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 用户书本收藏表 前端控制器
 * </p>
 *
 * @author YangXiong
 * @since 2023-04-18
 */
@Slf4j
@RestController
@RequestMapping("/book-collect")
public class BookCollectController {
    @Resource
    private BookCollectManager bookCollectManager;

    @PostMapping("/collect")
    @ApiOperation("根据id收藏一本书")
    public CommonResult<String> collect(@RequestBody CollectParam param){
        log.info("BookCollectController info collect CollectParam={}", param);
        return bookCollectManager.collect(param);
    }

    @PostMapping("/list")
    @ApiOperation("获取用户收藏列表")
    public CommonResult<List<BookMessageVo>> getByUserName(@RequestBody SysUserParam user){
        return bookCollectManager.getByUserName(user.getUserName());
    }

}

